package com.diaohw.module.file.obj.tables;

import com.diaohw.platform.framework.db.flex.obj.tables.BaseTableDef;
import com.mybatisflex.core.query.QueryColumn;

import java.io.Serial;

/**
 * 目录 表定义层。
 *
 * @author D-Hw
 * @since 2024-11-22 17:21:01
 */
public class CatalogDef extends BaseTableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 目录
     */
    public static final CatalogDef CATALOG = new CatalogDef();

    /**
     * 排序
     */
    public final QueryColumn SORT = new QueryColumn(this, "SORT");

    /**
     * 父节点ID
     */
    public final QueryColumn PARENT_ID = new QueryColumn(this, "PARENT_ID");

    /**
     * 目录类型
     */
    public final QueryColumn CATALOG_TYPE = new QueryColumn(this, "CATALOG_TYPE");
    /**
     * 目录CODE
     */
    public final QueryColumn CATALOG_CODE = new QueryColumn(this, "CATALOG_CODE");

    /**
     * 目录名称
     */
    public final QueryColumn CATALOG_NAME = new QueryColumn(this, "CATALOG_NAME");


    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{CATALOG_NAME, CATALOG_CODE, PARENT_ID, SORT};

    public CatalogDef() {
        super("", "CATALOG");
    }

    private CatalogDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public CatalogDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new CatalogDef("", "CATALOG", alias));
    }

}
